package com.bainuo.doctor.common.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;

/**
 * Created by bainuo on 2018/3/21.
 */

public class CustomRangTextView extends CustomTextView{


    private int color = 0;
    private boolean drawColor;

    public CustomRangTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomRangTextView(Context context) {
        super(context);
    }

    public void setBGColor(int color) {
        this.color = color;
        drawColor = true;
    }

    @Override
    protected void onDraw(Canvas canvas) {

        if (drawColor){

            if (getWidth() == 0) return;
            int width = getWidth();
            int height = getHeight();
            int r = height/10;


            Paint paint = new Paint();
            paint.setColor(color);
            canvas.drawRoundRect(new RectF(0,0,width,height),r,r,paint);
        }

        super.onDraw(canvas);

    }


}
